package com.guoheng.hazard.sys.controller.hazard;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.hazard.MonitorCameraInsertDTO;
import com.guoheng.hazard.sys.model.dto.hazard.MonitorCameraUpdateDTO;
import com.guoheng.hazard.sys.service.hazard.MonitorCameraService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　MonitorCameraController
 *
 * @author Eternal
 * @date 2019-11-20 17:54
 */
@RestController
@Validated
@Api(value = "摄像头信息")
public class MonitorCameraController {

    @Resource
    MonitorCameraService monitorCameraService;

    @ApiOperation(value = "查询摄像头列表信息")
    @GetMapping(value = "data/major/hazard/cameras")
    public Result getMonitorCameras(Long entprId, String entprName, String cameraNo, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return monitorCameraService.getMonitorCameras(entprId, entprName, cameraNo, pageNum, pageSize);
    }

    @ApiOperation(value = "修改摄像头信息")
    @PutMapping(value = "data/major/hazard/camera")
    public Result updateMonitorCamera(@RequestBody @Valid MonitorCameraUpdateDTO monitorCameraUpdateDTO) {
        return monitorCameraService.updateMonitorCamera(monitorCameraUpdateDTO);
    }

    @ApiOperation(value = "新增摄像头信息")
    @PostMapping(value = "data/major/hazard/camera")

    public Result insertMonitorCamera(@RequestBody @Valid MonitorCameraInsertDTO monitorCameraInsertDTO) {
        return monitorCameraService.insertMonitorCamera(monitorCameraInsertDTO);
    }

    @ApiOperation(value = "删除摄像头信息")
    @DeleteMapping(value = "data/major/hazard/camera/{id}")
    public Result deleteMonitorCamera(@PathVariable @NotNull Long id) {
        return monitorCameraService.deleteMonitorCamera(id);
    }

    @ApiOperation(value = "查询摄像头详情信息")
    @GetMapping(value = "data/major/hazard/camera/{id}")
    public Result getMonitorCamera(@PathVariable @NotNull Long id) {
        return monitorCameraService.getMonitorCamera(id);
    }

}